//
//  LTGroupManager.h
//  LTChat
//
//  Created by 俊松何 on 2017/7/26.
//  Copyright © 2017年 俊松何. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LTGroup.h"
#import "LTError.h"
#import "LTMessage.h"
#import "LTRecommendGroups.h"
@class LTGroupConfig;
@interface LTGroupManager : NSObject


/**
 创建群

 @param name             群名字
 @param description      群描述
 @param Invitees         群成员数组
 @param message          创建消息
 @param completionBlock  完成的block
 */
-(void)createGroupWithName:(NSString *)name
                 description:(NSString *)description
                    invitees:(NSArray<LTUser *> *)Invitees
                     message:(NSString *)message
                  completion:(void(^)(LTGroup *aGroup, LTError *aError))completionBlock;



/**
 添加群成员

 @param aUsers    要添加的群成员的数组
 @param aGroupId  群id
 @param aMessage  加入消息
 @param completionBlock 完成的block回调
 */
- (void)addMembers:(NSArray<LTUser *> *)aUsers
           toGroup:(NSString *)aGroupId
           message:(NSString *)aMessage
        completion:(void(^)(LTGroup *aGroup, LTError *aError))completionBlock;


- (void)removeMembersWithGroup:(LTGroup *)group
                   removeUsers:(NSArray<LTUser *> *)removeUsers
                       message:(NSString *)aMessage
                    completion:(void(^)(LTGroup *aGroup, LTError *aError))completionBlock;


/**
 解散群

 @param groupId 群id
 @param completionBlock 完成的回调
 */
- (void)destroyGroup:(NSString *)groupId
    finishCompletion:(void(^)(LTError *aError))completionBlock;



/**
 群成员退出群

 @param groupId 群id
 @param completionBlock 完成block
 */
- (void)leaveGroup:(NSString *)groupId
        completion:(void(^)(LTError *aError))completionBlock;



/**
 通过群id得到群组详情

 @param groupId 群id
 @return  群组对象
 */
- (LTGroup *)getGroupWithGroupId:(NSString *)groupId;

/**
 通过群id删除本地群聊
 
 @param groupId 群id
 @return  群组对象
 */
- (BOOL)deleteGroupWithGroupId:(NSString *)groupId;



/**
 通过群id得到群组详情

 @param groupId 群id
 @param completionBlock 完成的block
 */
-(void)getGroupDetailFromServerWithGroupId:(NSString *)groupId
                                completion:(void(^)(LTGroup *aGroup, LTError *aError))completionBlock;


//改变群名字
-(void)changeGroupNameWithGroup:(LTGroup *)group
                             name:(NSString *)name
                       completion:(void(^)(LTGroup *aGroup,LTMessage *uiMessage, LTError *aError))completionBlock;;


//改变群公告
-(void)changeGroupNoticeWithGroup:(LTGroup *)group
                           notice:(NSString *)notice
                       completion:(void(^)(LTGroup *aGroup,LTMessage *uiMessage, LTError *aError))completionBlock;


//保存群聊到通讯录
-(void)saveContactGroupWithGroup:(LTGroup *)group
                      completion:(void(^)(LTGroup *group, LTError *aError))completionBlock;


//从通讯录移除群聊
-(void)removeContactGroupWithGroup:(LTGroup *)group
                        completion:(void(^)(LTError *aError))completionBlock;

/**
 退出群聊

 @param group 群组
 @param completionBlock 完成的block
 */
-(void)quitGroupWithGroup:(LTGroup *)group
               completion:(void(^)(LTError *aError))completionBlock;

/**
 获取所有的群租列表

 @param completionBlock 回调
 */
-(void)getAllGroupFromServerWithCompletion:(void(^)(NSArray<LTGroup *> *groups, LTError *aError))completionBlock;



/**
 获取推荐群租

 @param completionBlock 完成的block
 */
-(void)getRecommendGroupFromServerWithCompletion:(void(^)(NSArray<LTRecommendGroups *> *recomendgroups, LTError *aError))completionBlock;


//获取本地所有群列表
-(NSArray<LTGroup *> *)getGroupListFromLocal;



/**
 获取群配置信息(先从本地数据去去查找，没找到在去服务器去取)
 
 @param groupId    好友的userId
 @param CompletionBlock 获取完成的blcok
 */
-(void)getGroupConfigWithGroupId:(NSString *)groupId
                      completion:(void(^)(LTGroupConfig *userConfig,LTError *ltrror))CompletionBlock;


/**
 更新群组配置信息

 @param groupconfig 群组配置
 @param CompletionBlock 完成的block
 */
-(void)updateGroupConfigWithGroupConfig:(LTGroupConfig *)groupconfig
                             completion:(void(^)(LTGroupConfig *userConfig,LTError *ltrror))CompletionBlock;

@end
